<script>
 $(document).ready(function(){
	    $("#mod_id").change(function(){
	         var mod_id = $(this).val();
	         if(mod_id!=""){
	    	 $.ajax({
	        	   type: "POST",
	        	   url:"<?php echo  base_url();?>administrator/get_category",
	        	   data: "mod_id="+mod_id,
	        	   success: function(msg){
	            	   $("#category_id").html("");
	            	   $("#category_id").html(msg);
	            	   $("#update_historys_form").submit();
	        	   }
	          });   
	         }else{
	        	 $("#update_historys_form").submit();
	         }
	     })     

	    $("#category_id").change(function(){
	         $("#update_historys_form").submit();
	     })
	     $("#company_id").change(function(){
	         $("#update_historys_form").submit();
	     })
 })
</script> 
<style>
.bs{ background-color:#FF0000;}
</style>
		<div id="center-column">
			<div class="top-bar">
				
				<h1>Contents</h1>
				<div class="breadcrumbs"><?php echo anchor('main/index','首页');?> / <?php echo anchor('administrator/update_historys','资料更新管理');?></div>
			</div><br />
		 <div class="select-bar">
		  <?php echo form_open('administrator/update_historys',array('id'=>'update_historys_form'));?> 
		    <label>型号：</label><label><select id="mod_id" name="mod_id">
		                      <option value="">全部型号</option>
		                   <?php foreach($mod as $k=>$val){?>
		                      <option value="<?php echo $val->mod_id;?>" <?php if(isset($mod_id)&&($mod_id==$val->mod_id)){?>selected=true<?php }?>><?php echo $val->name;?></option>
		                   <?php }?>
		                 </select>
		    </label>
		    <label>种类：</label>
		    <label><select id="category_id" name="category_id"><option value="">全部资料种类</option></select></label>
		    <label>发放单位：</label><label><select id="company_id" name="company_id">
		                      <option value="">全部发放单位</option>
		                   <?php foreach($company as $k=>$val){?>
		                      <option value="<?php echo $val->company_id;?>" <?php if(isset($company_id)&&($company_id==$val->company_id)){?>selected=true<?php }?>><?php echo $val->name;?></option>
		                   <?php }?>
		                 </select>
		    </label>

			<label>单号：</label>
			<label>
			<input type="text" name="codes" id="codes" value="<?php echo $codes;?>" />
			</label>
		    <label>
			<input type="submit" name="Submit" value="搜索" />
			</label>
		  </form>	
		  </div>
			<div class="table">
				
				
				<table class="listing" cellpadding="0" cellspacing="0">
					<tr>
						<th width="17">ID</th>
						<th>型号</th>
						<th>资料种类</th>						
						<th>更新前版本</th>
						<th>更新后版本</th>
						<th>更新单据号</th>
						<th>发放单位</th>
						<th>份数</th>						
						<th>更新时间</th>					
						<!-- <th >操作</th> -->
					</tr>
			    <?php foreach($update_historys as $k=>$val):if($val->count!=0){?>		
					<!-- <tr <?php if($val->is_update==1||$val->is_update==2){?> class="bs" <?php }?> > -->
					<tr>
                        <td><?php echo $start;?></td> 
                        <td><?php foreach($mod as $j=>$m){ if($val->mod_id==$m->mod_id){echo $m->name;}}?></td>
                        <td style="text-align:left;padding-left:5px;width:300px;"><?php foreach($category as $j=>$m){ if($val->category_id==$m->category_id){echo $m->name;}}?></td>
                                               
                        <td><?php foreach($version as $j=>$m){ if($val->pre_version==$m->version_id){echo $m->name;}}?></td>
                        <td><?php foreach($version as $j=>$m){ if($val->version_id==$m->version_id){echo $m->name;}}?></td>
                        <td><?php echo $val->codes;?></td>  
                        <td><?php foreach($company as $j=>$m){ if($val->company_id==$m->company_id){echo $m->name;}}  if($val->company_id==0){ echo '库存';}?></td>
                        <td><?php echo $val->count;?></td>
                        <td><?php echo $val->updatetime;?></td>
                        <!-- <td><?php echo anchor('administrator/send_detail/'.$val->send_id,'查看',array('class'=>'send_detail'));?>&nbsp;&nbsp;|&nbsp;&nbsp;<?php echo anchor('administrator/send_edit/'.$val->send_id,'编辑',array('class'=>'mod_edit'));?></td> -->
					</tr>
				<?php $start++;}  endforeach;?>						
				</table>
				<?php echo $page;?>
			</div>
		</div>
	</div>
	
	<div id="footer"></div>
</div>
<input type="hidden" id="version_mod_id" value="<?php echo $mod_id;?>"/>
<input type="hidden" id="version_category_id" value="<?php echo $category_id;?>"/>
<input type="hidden" id="version_company_id" value="<?php echo $company_id;?>"/>
</body>
</html>
<script>
  $(document).ready(function(){
	  var mod_id = $("#version_mod_id").val();
	  var category_id = $("#version_category_id").val();
	  var company_id = $("#version_company_id").val();
		 $.ajax({
		  	   type: "POST",
		  	   url:"<?php echo  base_url();?>administrator/get_category",
		  	   data: "mod_id="+mod_id,
		  	   success: function(msg){
		      	   $("#category_id").html("");
		      	   $("#category_id").html(msg);
			      	 $("select[name=category_id]").val(category_id);
				     $("select[name=company_id]").val(company_id);
		  	   }
		    });
   })
</script>
